package com.tan.dao.impl;

import com.tan.dao.UserDao;
import com.tan.po.User;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

public class UserDaoImpl implements UserDao {
    private SqlSessionFactory sqlSessionFactory;
    public UserDaoImpl(SqlSessionFactory sqlSessionFactory){
        this.sqlSessionFactory=sqlSessionFactory;
    }
    @Override
    public List<User> findAll() {
        //打开session
        SqlSession sqlSession = sqlSessionFactory.openSession();
        //执行sql语句
        List<User> list = sqlSession.selectList("userMapper.selectAll");
        return list;
    }
}
